package com.buptlogistics.creditinvestigation.fragment;


import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.buptlogistics.creditinvestigation.R;
import com.buptlogistics.creditinvestigation.activity.CommonActivity;
import com.buptlogistics.creditinvestigation.app.BaseFragment;
import com.buptlogistics.creditinvestigation.utils.ToastUtil;

/**
 * 审批贷款申请界面
 */
public class DeserveApplyFragment extends BaseFragment {
    private View view;

    private Button btn_accept;

    public DeserveApplyFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_deserve_apply, container, false);
        initViews();
        initEvents();
        return view;
    }

    protected void initViews() {
        btn_accept = (Button) findViewById(R.id.btn_deserve_apply_accept);
    }

    protected void initEvents() {
        btn_accept.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AlertDialog.Builder builder = new AlertDialog.Builder(DeserveApplyFragment.this
                        .getActivity());
                builder.setMessage("您确定同意" + "xx" + "发送的融资申请吗？");
                builder.setPositiveButton("是", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Bundle data = new Bundle();
                        data.putInt("fragmentType", 6);
                        // 创建一个Intent
                        Intent intent = new Intent(DeserveApplyFragment.this.getActivity(),
                                CommonActivity.class);
                        intent.putExtras(data);
                        // 启动intent对应的Activity
                        startActivity(intent);
                    }
                });
                builder.setNegativeButton("否", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        ToastUtil.showToast(DeserveApplyFragment.this.getActivity(), "否");
                    }
                });
                builder.show();

            }
        });
    }

    protected View findViewById(int id) {
        return view.findViewById(id);
    }

}
